import {request} from '@/utils/request'
import type {CodeType, Patient, PatientList, User, UserInfo} from '@/types/user' // 密码登录

// 密码登录
export const loginByPassword = (mobile: string, password: string) => {
  return request<User>('login/password', 'POST', { mobile, password })
}

// 获取验证码
export const getLoginByCode = (mobile: string, type: CodeType) => {
  return request<User>('code', 'get', { mobile, type })
}

// 验证码登录
export const loginByCode = (mobile: string, code: string) => {
  return request<User>('login', 'POST', { mobile, code })
}

// 获取用户信息
export const getUserInfo = () => {
  return request<UserInfo>('patient/myUser')
}

// ----------家庭档案---------------
// 获取患者信息
export const getPatientInfo = () => {
  return request<PatientList>(`patient/mylist`)
}

// 添加患者
export const addPatient = (patient: Patient) => {
  return request<{ id: string }>(`patient/add`, 'POST', patient)
}

// 编辑患者
export const editPatient = (patient: Patient) => {
  return request<{ id: string }>(`/patient/update`, 'PUT', patient)
}

// 删除患者
export const removePatient = (id: string) => {
  return request<{ id: string }>(`/patient/del/${id}`, 'DELETE')
}
